from items.Book import Book
from model import GameMap
from view.blockImgs import BlockImg
from view.blockImgs.Text import Text


class Hero:
    level = 1
    hp = 200
    attack = 40
    defense = 0
    money = 0
    x_location = 13
    y_location = 13
    direction = [0, 0, 0]  # x, y, face
    step = 0
    yellowKey = 2
    purpleKey = 0
    redKey = 0
    item_list = [Book()]

    def __init__(self):
        pass

    @staticmethod
    def update():
        if Hero.hp <= 0:
            # TODO 死亡界面
            print("dead")
            BlockImg.BlockImg("resources/字/fgt_box.png",25,41,multiple=4.0)
            Text(11.5,7,size=60).text="已死亡"
        if 21 > Hero.x_location + Hero.direction[0] >= 0 and 15 > Hero.y_location + Hero.direction[1] >= 0:
            if GameMap.GameMap.game_event[Hero.x_location + Hero.direction[0]][
                Hero.y_location + Hero.direction[1]].isWork:
                GameMap.GameMap.game_event[Hero.x_location + Hero.direction[0]][
                    Hero.y_location + Hero.direction[1]].trigger()
            else:
                GameMap.GameMap.game_map[Hero.x_location + Hero.direction[0]][
                    Hero.y_location + Hero.direction[1]].trigger()
        else:
            Hero.direction = [0, 0, Hero.direction[2]]
            Hero.step = Hero.step % 4
